import { axios } from '@/utils/request'

/**
 * 查询缓存详细
 * @returns {*}
 */
export function getCache() {
  return axios({
    url: '/monitor/cache',
    method: 'get'
  })
}

/**
 * 查询缓存名称列表
 * @returns {*}
 */
export function listCacheName() {
  return axios({
    url: '/monitor/cache/getNames',
    method: 'get'
  })
}

/**
 * 查询缓存键名列表
 * @param cacheName
 * @returns {*}
 */
export function listCacheKey(cacheName) {
  return axios({
    url: '/monitor/cache/getKeys/' + cacheName,
    method: 'get'
  })
}

/**
 * 查询缓存内容
 * @param cacheName
 * @param cacheKey
 * @returns {*}
 */
export function getCacheValue(cacheName, cacheKey) {
  return axios({
    url: '/monitor/cache/getValue/' + cacheName + '/' + cacheKey,
    method: 'get'
  })
}

/**
 * 清理指定名称缓存
 * @param cacheName
 * @returns {*}
 */
export function clearCacheName(cacheName) {
  return axios({
    url: '/monitor/cache/clearCacheName/' + cacheName,
    method: 'delete'
  })
}

/**
 * 清理指定键名缓存
 * @param cacheName
 * @param cacheKey
 * @returns {*}
 */
export function clearCacheKey(cacheName, cacheKey) {
  return axios({
    url: '/monitor/cache/clearCacheKey/'+ cacheName + "/" + cacheKey,
    method: 'delete'
  })
}

/**
 * 清理全部缓存
 * @returns {*}
 */
export function clearCacheAll() {
  return axios({
    url: '/monitor/cache/clearCacheAll',
    method: 'delete'
  })
}
